<?php
/**
 * Created by JetBrains PhpStorm.
 * User: Đặng Khánh Trung
 * Date: 10/28/12
 * Time: 4:11 PM
 * To change this template use File | Settings | File Templates.
 */
// no direct access
defined('_JEXEC') or die;

JHtml::addIncludePath(JPATH_COMPONENT . '/helpers/html');
JHtml::_('behavior.tooltip');
JHtml::_('behavior.multiselect');
JHtml::_('behavior.mootools');

JLoader::register('MucChon', JPATH_COMPONENT . '/helpers/mucchon.php');

$document = JFactory::getDocument();
$document->addStyleSheet(JURI::base() . 'components/com_vast/assets/css/admin_ui.css');
$document->addStyleSheet(JURI::base() . 'components/com_vast/assets/css/mystyle.css');
$document->addStyleSheet(JURI::base() . 'components/com_vast/assets/css/admin_menu.css');
$document->addStyleSheet(JURI::base() . 'components/com_vast/assets/css/admin.styles.css');
$document->addStyleSheet(JURI::base() . 'components/com_vast/assets/css/toolbar_images.css');
$document->addStyleSheet(JURI::base() . 'components/com_vast/assets/css/menu_images.css');

$document->addStyleSheet(JURI::root() . 'components/com_vast/assets/css/chosen.css');
$document->addStyleSheet(JURI::root() . 'components/com_vast/assets/css/vtip.css');
$document->addStyleSheet(JURI::root() . 'components/com_vast/assets/js/fancybox/jquery.fancybox-1.3.4.css');

$document->addScript(JURI::root() . 'components/com_vast/assets/js/jquery.min.js');
$document->addScript(JURI::root() . 'components/com_vast/assets/js/jquery-ui.min.js');
$document->addScript(JURI::root() . 'components/com_vast/assets/js/jquery.ui.autocomplete.html.js');
$document->addScript(JURI::root() . 'components/com_vast/assets/js/jquery.noConflict.js');
$document->addScript(JURI::root() . 'components/com_vast/assets/js/vmsite.js');
$document->addScript(JURI::root() . 'components/com_vast/assets/js/fancybox/jquery.mousewheel-3.0.4.pack.js');
$document->addScript(JURI::root() . 'components/com_vast/assets/js/fancybox/jquery.easing-1.3.pack.js');
$document->addScript(JURI::root() . 'components/com_vast/assets/js/fancybox/jquery.fancybox-1.3.4.pack.js');
$document->addScript(JURI::base() . 'components/com_vast/assets/js/jquery.coookie.js');
$document->addScript(JURI::root() . 'components/com_vast/assets/js/chosen.jquery.min.js');
$document->addScript(JURI::base() . 'components/com_vast/assets/js/vm2admin.js');

$document->addScriptDeclaration('
		var tip_image=\'/joomla/components/com_virtuemart/assets/js/images/vtip_arrow.png\';
		var vm2string ={ editImage: \'edit image\',select_all_text: \'select all options\',select_some_options_text :\'Select some Options\', select_an_option_text:\'Select an Option\'} ;
		 jQuery( function($) {

			$(\'dl#system-message\').hide().slideDown(400);
			$(\'.virtuemart-admin-area .toggler\').vm2admin(\'toggle\');
			$(\'#admin-ui-menu\').vm2admin(\'accordeon\');
			if ( $(\'#admin-ui-tabs\').length  ) {
				$(\'#admin-ui-tabs\').vm2admin(\'tabs\',virtuemartcookie).find(\'select\').chosen({enable_select_all: true,select_all_text : vm2string.select_all_text,select_some_options_text:vm2string.select_some_options_text});
			}

			$(\'#content-box [title]\').vm2admin(\'tips\',tip_image);
			$(\'.modal\').fancybox();
			$(\'.reset-value\').click( function(e){
                e.preventDefault();
                none = \'\';
                jQuery(this).parent().find(\'.ui-autocomplete-input\').val(none);

            });

		});

		var virtuemartcookie="virtuemart";

');

$user = JFactory::getUser();
$userId = $user->get('id');
$listOrder = $this->escape($this->state->get('list.ordering'));
$listDirn = $this->escape($this->state->get('list.direction'));
$saveOrder = $listOrder == 'a.ordering';
?>

<div class="virtuemart-admin-area">
    <?php 
        $mucchon = new MucChon();
        echo $mucchon->layMucChon();
    ?>

    <div id="admin-content-wrapper">
        <div class="toggler vmicon-show"></div>
        <div id="admin-content" class="admin-content">

            <form action="<?php echo JRoute::_('index.php?option=com_vast&view=viens');?>" method="post"
                  name="adminForm" id="adminForm">
                <table class="adminlist">
                    <thead>
                    <tr>
                        <th width="1%">
                            <input type="checkbox" name="checkall-toggle" value=""
                                   title="<?php echo JText::_('JGLOBAL_CHECK_ALL'); ?>"
                                   onclick="Joomla.checkAll(this)"/>
                        </th>
                        <th>
                            Hình ảnh
                        </th>
                        <th>
                            <?php echo JHtml::_('grid.sort', 'Giới thiệu', 'a.gioithieu', $listDirn, $listOrder); ?>
                        </th>
                        <th>
                            Cơ sở vật chất
                        </th>
        				<th width="5%">
        					<?php echo JHtml::_('grid.sort', 'JSTATUS', 'a.published', $listDirn, $listOrder); ?>
        				</th>
                        <th width="1%" class="nowrap">
                            <?php echo JHtml::_('grid.sort', 'JGRID_HEADING_ID', 'a.id', $listDirn, $listOrder); ?>
                        </th>
                    </tr>
                    </thead>
                    <tfoot>
                    <tr>
                        <td colspan="6">
                            <?php echo $this->pagination->getListFooter(); ?>
                        </td>
                    </tr>
                    </tfoot>
                    <tbody>

                    <?php foreach ($this->items as $i => $item) :
                        $canEdit = $user->authorise('core.edit', 'com_vast.vien.' . $item->id);
    				    $canCheckin	= $user->authorise('core.admin', 'com_checkin') || $item->checked_out == $userId || $item->checked_out == 0;
    				    $canChange	= $user->authorise('vast.vien.edit', 'com_vast') && $canCheckin;
                        ?>

                    <tr class="row<?php echo $i % 2; ?>">
                        <td class="center" valign="top">
                            <?php echo JHtml::_('grid.id', $i, $item->id); ?>
                        </td>
                        <td valign="top">
                            <img src="<?php echo JURI::root() . $item->hinhanh; ?>" alt="Viện khoa học và công nghệ Việt Nam"
                                 width="200" height="120"/>
                        </td>
                        <td valign="top">
                            <?php if ($canEdit): ?>
                            <a href="<?php echo JRoute::_('index.php?option=com_vast&task=vien.edit&id=' . $item->id);?>">
                                <?php echo JHtml::_('string.truncate', strip_tags($item->gioithieu), 200); ?></a>
                            <?php else : ?>
                            <?php echo JHtml::_('string.truncate', strip_tags($item->gioithieu), 200); ?>
                            <?php endif; ?>
                        </td>
                        <td valign="top">
                            <?php echo JHtml::_('string.truncate', strip_tags($item->cosovatchat), 200); ?>
                        </td>
    					<td class="center">
    						<?php echo JHtml::_('jgrid.published', $item->published, $i, 'viens.', $canChange);?>
    					</td>
                        <td class="center" valign="top">
                            <?php echo (int)$item->id; ?>
                        </td>
                    </tr>
                        <?php endforeach; ?>
                    </tbody>
                </table>

                <?php //Load the batch processing form. ?>

                <div>
                    <input type="hidden" name="task" value=""/>
                    <input type="hidden" name="boxchecked" value="0"/>
                    <input type="hidden" name="filter_order" value="<?php echo $listOrder; ?>"/>
                    <input type="hidden" name="filter_order_Dir" value="<?php echo $listDirn; ?>"/>
                    <?php echo JHtml::_('form.token'); ?>
                </div>
            </form>
        </div>
    </div>
</div>